package com.mq.rocketmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: 19239
 * @Description:
 * @Date: 2024/6/27
 * @Version: 1.0
 */
@Component
@Slf4j
@Order(Integer.MIN_VALUE)
//// 设置消息模型为广播模式:MessageModel.BROADCASTING,
@RocketMQMessageListener(consumerGroup = "MessageListener2-group", topic = "topicDifListener", selectorExpression = "*"
        )
public class MessageListener2 implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        log.info(" MessageListener2 = received: {},receive time: {}", message, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}
